<%--
  Created by IntelliJ IDEA.
  User: 22328
  Date: 2021/2/12
  Time: 22:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>焕耀商城－商品列表</title>
    <link rel="stylesheet" type="text/css" href="./css/reset.css">
    <link rel="stylesheet" type="text/css" href="./css/main.css">
    <script type="text/javascript" src="./js/jquery-3.1.0.min.js"></script>
</head>
<body>
<!--头部开始-->
<jsp:include page="top.jsp"/>
<!--头部结束-->

<div class="search_bar clearfix">
    <a href="./main" class="logo fl"><img src="./images/logo.png"></a>
    <div class="search_con fl">
        <form method="get" action="./readMoreGoods" target="_self">
            <input type="text" class="input_text fl" id="desc" name="desc" value="${desc==null?"":desc}" placeholder="搜索商品">
            <input type="text" name="page" value="1" style="display: none">
            <input type="text" name="limit" value="12" style="display: none">
            <input type="submit" class="input_btn fr" value="搜索">
        </form>
    </div>
    <div class="guest_cart fr">
        <c:if test="${sessionScope.user!=null}">
            <a href="./getCartHtml" class="cart_name fl">我的购物车</a>
            <div class="goods_count fl" id="show_count">${sessionScope.user.cartBuyNums}</div>
        </c:if>
        <c:if test="${sessionScope.user==null}">
            <a href="./login" class="cart_name fl">我的购物车</a>
            <div class="goods_count fl" id="show_count"></div>
        </c:if>
    </div>
</div>

<div class="navbar_con">
    <div class="navbar clearfix">
        <div class="subnav_con fl">
            <h1>全部商品分类</h1>
            <span></span>
            <ul class="subnav">
                <li><a href="./readMoreGoods?categoryId=1&page=1&limit=12" >衣物</a></li>
                <li><a href="./readMoreGoods?categoryId=2&page=1&limit=12" >美妆</a></li>
                <li><a href="./readMoreGoods?categoryId=3&page=1&limit=12" >书籍</a></li>
                <li><a href="./readMoreGoods?categoryId=4&page=1&limit=12" >电子</a></li>
                <li><a href="./readMoreGoods?categoryId=5&page=1&limit=12" >玩具</a></li>
                <li><a href="./readMoreGoods?categoryId=6&page=1&limit=12" >食物</a></li>
            </ul>
        </div>
        <ul class="navlist fl">
            <li><a href="./main">首页</a></li>
            <li class="interval">|</li>
            <li><a href="#">手机商城</a></li>
            <li class="interval">|</li>
            <li><a href="#">抽奖</a></li>
        </ul>
    </div>
</div>

<div class="breadcrumb">
    <a href="./main">全部分类</a>
    <span>&gt;</span>
    <c:if test="${goods[0].categoryId==1}">
        <a href="#">衣物</a>
    </c:if>
    <c:if test="${goods[0].categoryId==2}">
        <a href="#">美妆</a>
    </c:if>
    <c:if test="${goods[0].categoryId==3}">
        <a href="#">书籍</a>
    </c:if>
    <c:if test="${goods[0].categoryId==4}">
        <a href="#">电子</a>
    </c:if>
    <c:if test="${goods[0].categoryId==5}">
        <a href="#">玩具</a>
    </c:if>
    <c:if test="${goods[0].categoryId==6}">
        <a href="#">食物</a>
    </c:if>
</div>

<div class="main_wrap clearfix">
    <div class="l_wrap fl clearfix">
        <div class="new_goods">
            <h3>新品推荐</h3>
            <ul>
                <c:forEach items="${goods}" var="good" end="1">
                    <li>
                        <a href="./goodsDetail?id=${good.id}"><img src="${good.goodsImg}"></a>
                        <h4><a href="./goodsDetail?id=${good.id}">${good.goodsName}-${good.goodsDesc}</a></h4>
                        <div class="prize">￥${good.goodsPrice}</div>
                    </li>
                </c:forEach>
            </ul>
        </div>
    </div>

    <div class="r_wrap fr clearfix">
        <div class="sort_bar">

            <a href="#" class="active">默认</a>
            <a href="#">价格</a>
            <a href="#">人气</a>

        </div>

        <ul class="goods_type_list clearfix">
            <c:forEach items="${goods}" var="good">
                <li>
                    <a href="./goodsDetail?id=${good.id}"><img src="${good.goodsImg}"></a>
                    <h4><a href="http://ttsx.newzn.cn/goods/detail/45">${good.goodsName}-${good.goodsDesc}</a></h4>
                    <div class="operate">
                        <span class="prize">￥${good.goodsPrice}</span>
                        <span class="unit">${good.goodsPrice}元/件</span>
                        <a href="javascript:;" class="add_goods" title="加入购物车"></a>
                        <span id="span1id" style="display: none">45</span>
                    </div>
                </li>
            </c:forEach>
        </ul>
        <div class="pagenation">
            <a class="active">1</a>
        </div>
    </div>
</div>

<!--底部 开始-->
<jsp:include page="bottom.jsp"/>
<!--底部 结束-->

<script>
    $(".add_goods").click(function () {

        $.get("/cart/updatecart/add/1/"+$(this).next().html()+"/1",function (data) {
            if (data.data != 0){
                $("#show_count").html(data.data);
            }
        });

    });
</script>
</body>
</html>
